<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>邮件服务设置页面</title>
<!-- BEGIN 页面公共文件 -->
<load href="__COMMON__/css/init.css" />
<load href="__COMMON__/css/font-icons.css" />
<load href="__COMMON__/js/jquery.min.js" />
<!-- END 页面公共文件 -->

<!-- BEGIN 当前页面的css 和js -->
<load href="__COMMON__/css/tools/easydialog.css" />
<load href="__ADMIN_CSS__/common.css" />
<load href="__ADMIN_CSS__/sysconfig/system_setting.css" />
<load href="__COMMON__/js/tools/easydialog.min.js" />
<load href="__COMMON__/js/tools/Validator.js" />
<!-- END 当前页面的css 和js -->
    <style type="text/css">
        .forminfo li label.email {
            width: 120px;
        }
        .forminfo .input_disable{
            background: #e8e8e8;
        }
    </style>
</head>
<body>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="{:U('Index/main')}">主页</a></li>
    <li><a href="javascript::">邮件服务设置</a></li>
    </ul>
    <a class="reload" href="javascript:void(0)" onclick="window.location.reload()"><i class="fa fa-refresh"></i>重载此页面</a>
    </div>
    <div class="formbody">
    <div class="formtitle"><span>邮件服务设置</span></div>
        <form name="email_set" method="post" action="{:U('Sysconfig/mail')}" onsubmit="return check();">
    <ul class="forminfo">
	<li><label class="email"><b>*</b>enable</label>
        <label for="unable">&nbsp;&nbsp;<input name="enable" type="radio" id="unable" <eq name="email.enable" value="0">checked="checked"</eq> value="0"/>&nbsp;&nbsp;unenable</label>
        <label for="able">&nbsp;&nbsp;<input name="enable" type="radio" id="able" <eq name="email.enable" value="1">checked="checked"</eq> value="1"/>&nbsp;&nbsp;enable</label>
    </li>
	<li><label class="email"><b>*</b>Sender</label><input name="sender" type="text" class="dfinput <eq name="email.enable" value="0">input_disable</eq>" maxlength="100" value="{$email.sender}" <eq name="email.enable" value="0">disabled="disabled"</eq>/><i>用于显示在“发件人”处的文字</i></li>
	<li><label class="email"><b>*</b>SMTP Server</label><input name="smtp" type="text" class="dfinput <eq name="email.enable" value="0">input_disable</eq>" maxlength="100" value="{$email.smtp}" <eq name="email.enable" value="0">disabled="disabled"</eq>/></li>
	<li><label class="email"><b>*</b>SMTP Port</label><input name="smtp_port" type="text" class="dfinput <eq name="email.enable" value="0">input_disable</eq>" maxlength="100" value="{$email.smtp_port}" <eq name="email.enable" value="0">disabled="disabled"</eq>/></li>
	<li><label class="email"><b>*</b>email account</label><input name="email_account" type="text" class="dfinput <eq name="email.enable" value="0">input_disable</eq>" maxlength="100" value="{$email.email_account}" <eq name="email.enable" value="0">disabled="disabled"</eq>/><i style="display:block">用于发送邮件的邮箱帐号（此邮箱帐号一定要开通smtp功能，请在邮箱管理界面“设置”菜单中查看和设置）</i></li>
	<li><label class="email"><b>*</b>email password</label><input name="email_pass" type="password" class="dfinput <eq name="email.enable" value="0">input_disable</eq>" maxlength="100" value="{$email.email_pass}" <eq name="email.enable" value="0">disabled="disabled"</eq>/></li>
	<li><label class="email"><b>*</b>recieve email</label><textarea name="recieve_email" style="padding: 10px; width: 325px;height:50px;" <eq name="email.enable" value="0">disabled="disabled" class="input_disable"</eq>>{$email.recieve_email}</textarea><i style="display:block; padding-left:115px;">用于接收外来邮件的邮箱，回车换行，每行一个邮箱</i></li>
    <li><label >&nbsp;</label><input name="submit" type="submit" class="submit submitable "  value="确认设置"  />
        <i id="submit_tip" placeholder=""></i>
<input type="hidden" name="id" value="{$email.id|default=0}"/>
</li>
    </ul>
        </form>
</div>
</body>
</html>
<script type="text/javascript">
var $configSubmitUrl="{:U('Sysconfig/mail')}";
$(function (){
    $('input[name="enable"]').click(function () {
        $enable = parseInt($('input[name="enable"]:checked').val());
        $enable = isNaN($enable) ? 0 : $enable;
        if ($enable ==1) {
            $('input[type="text"],input[type="password"],input[type="submit"],textarea').attr('disabled', false).removeClass('input_disable');
         }else{
            $('input[type="text"],input[type="password"],textarea').attr('disabled', true).addClass('input_disable');
         }

    })

})
function check(){
    $enable = parseInt($('input[name="enable"]:checked').val());
    $enable = isNaN($enable) ? 0 : $enable;
    if ($enable ==1) {
        var     $smtp = $('input[name="smtp"]').val(),
                $smtp_port = $('input[name="smtp_port"]').val(),
                $email_account = $('input[name="email_account"]').val(),
                $email_pass = $('input[name="email_pass"]').val(),
                $recieve_email = $('textarea[name="recieve_email"]').val();
        if (is_empty($smtp)) {
            setTips('the SMTP Server is required!');
            return false;
        }
        if (!is_all_numbers($smtp_port)) {
            setTips('the SMTP port needs to be a number !');
            return false;
        }
        if (!is_email($email_account)) {
            setTips('email account is incorrect !');
            return false;
        }
        if (is_empty($email_pass)) {
            setTips('email password is required !');
            return false;
        }
        if (is_empty($recieve_email)) {
            setTips('recieve email password is required !');
            return false;
        }
    }
    return true;
}
function setTips(tips) {
   $('#submit_tip').html('<i style="color: #dd4e39;font-size:15px;padding-right: 5px;" class="fa fa-exclamation-circle"></i><span style="color: #D31B26;">'+ tips + "</span>");
}
</script>